﻿namespace ApophysisCS
{
    #region Imported Namespaces
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    #endregion

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        #region Members
        private EditorWindow editorWindow;
        #endregion

        public MainWindow()
        {
            InitializeComponent();
        }

        private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (this.editorWindow != null)
            {
                this.editorWindow.CloseWindow();
                this.editorWindow = null;
            }
        }

        private void OnExecuteShowEditor(object sender, ExecutedRoutedEventArgs e)
        {
            if (this.editorWindow == null)
            {
                this.editorWindow = new EditorWindow();
            }

            if (!this.editorWindow.IsVisible)
            {
                this.editorWindow.Show();
            }
            else if (this.editorWindow.WindowState == WindowState.Minimized)
            {
                this.editorWindow.WindowState = WindowState.Normal;
            }
            else if (!this.editorWindow.IsActive)
            {
                this.editorWindow.Activate();
            }
        }
    }
}
